﻿<Views:WindowBase x:Class="SharpTalk.Client.WpfApplication.Views.UserView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Views="clr-namespace:SharpTalk.Client.WpfApplication.Views" 
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:Resources="clr-namespace:SharpTalk.Client.WpfApplication.Resources"
        xmlns:Controls="clr-namespace:SharpTalk.Client.WpfApplication.Controls"
        d:DesignHeight="250" d:DesignWidth="600" 
        Style="{StaticResource MessageViewStyle}" 
        MinWidth="420" MinHeight="250"
        MaxWidth="420" MaxHeight="250"
        ResizeMode="NoResize"
        Title="{x:Static Resources:Messages.label_create_new}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
            <Grid Grid.Row="0" IsEnabled="{Binding  HasUser}" Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock Text="{x:Static Resources:Messages.label_firstname}" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2"/>
                <TextBox Text="{Binding CurrentUser.FirstName}" Grid.Column="1" VerticalAlignment="Center"  Margin="2"/>
                <TextBlock Text="{x:Static Resources:Messages.label_lastname}" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2"/>
                <TextBox Text="{Binding CurrentUser.LastName}" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="2"/>
                <TextBlock Text="{x:Static Resources:Messages.label_nickname}" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2"/>
                <TextBox Text="{Binding CurrentUser.NickName}" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="2"/>
                <GroupBox Header="{x:Static Resources:Messages.label_images}" Grid.Row="3" Grid.ColumnSpan="2">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" Source="{Binding CurrentUser.Image, Converter={StaticResource BinaryToBitmapImageConverter}}" Style="{StaticResource ImageLargeStyle}" >
                        <Image.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="{x:Static Resources:Messages.label_image_select}" Command="{Binding SelectImageCommand}"/>
                                <MenuItem Header="{x:Static Resources:Messages.label_image_clear}" Command="{Binding ClearImageCommand}"/>
                            </ContextMenu>
                        </Image.ContextMenu>
                    </Image>
                    <ListBox
                        Height="Auto"
                        Grid.Column="1"
                        ItemsSource="{Binding Images}"
                        Style="{StaticResource ImageListBoxStyle}"
                        SelectedItem="{Binding CurrentUser.Image, Converter={StaticResource BinaryToBitmapImageConverter}}">
                    </ListBox>
                    </Grid>
                </GroupBox>
            </Grid>

        <Controls:DialogActionsPanel
            Grid.Row="1" 
            Grid.ColumnSpan="2"
            HorizontalAlignment="Right"
            VerticalAlignment="Bottom"
            ShowButtonOk="{Binding HasUser, Converter={StaticResource ReversedBooleanToBoolConverter}}"
            ShowButtonCancel="True"
            ShowButtonYes="{Binding HasUser}"
            ButtonOkContent="{x:Static Resources:Messages.label_create_new}"
            ButtonOkCommand="{Binding CreateNewCommand}"
            ButtonYesContent="{x:Static Resources:Messages.label_save}"
            ButtonYesCommand="{Binding ValidateCommand}" />
    </Grid>
</Views:WindowBase>
